﻿using Google.Protobuf;
using Server.Framework.Message;
using Server.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Server.Message.Response
{
    /// <summary>
    /// Author: Leil
    /// Description: 角色列表回复消息
    /// CreateTime: 2020/5/13 12:31:32
    /// </summary>
    class MenuListResp : ResponseBaseMessage
    {
        public List<MenuDao> Menus { get; } = new List<MenuDao>();

        public int Count { get; set; }

        public MenuListResp(int msgId):base(msgId)
        {

        }

        public override byte[] Serialize()
        {
            MenuList msg = new MenuList();
            Menus.ForEach(menu =>
            {
                Menu m = new Menu
                {
                    Id = menu.ID,
                    ParentId = menu.ParentId,
                    Icon = menu.Icon,
                    ScreenCode = menu.ScreenCode ?? "",
                    MenuName = menu.MenuName ?? "",
                    MenuType = menu.MenuType,
                    Sort = menu.Sort,
                    Status = menu.Status,
                    Creator = menu.Creator ?? "",
                    CreateTime = menu.CreateTime ?? "",
                    Updator = menu.Updator ?? "",
                    UpdateTime = menu.UpdateTime ?? "",
                };
                msg.Menus.Add(m);
            });
            msg.Count = Count;
            return msg.ToByteArray();
        }
    }
}
